package lancamento;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.text.MaskFormatter;

import principal.JFPrincipal;

import javax.swing.ImageIcon;

@SuppressWarnings("serial")
public class JIFLancamento extends JDialog {

	private JPanel contentPane;
	private JPanel fieldPane;
	private JPanel baixaPane;
	private JPanel balancePane;
	private JPanel buttonPane;
	private JTable table;
	private JFormattedTextField ftPagamento;
	private JLabel lbVl_Vencimento;
	private MaskFormatter mfd;
	private SimpleDateFormat sdf;
	private DecimalFormat df;

	public JIFLancamento(JFPrincipal fPrincipal) throws SQLException,
			ClassNotFoundException, ParseException {
		super(fPrincipal);
		setBounds(100, 100, 806, 407);
		setTitle("Ger\u00EAncia de Lan\u00E7amentos");
		setModal(true);

		/*************** content Pane *****************/
		contentPane = new JPanel(new BorderLayout());
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);

		mfd = new MaskFormatter("##/##/####");
		sdf = new SimpleDateFormat("dd/MM/yyyy");
		df = new DecimalFormat("###,##0.00");

		/***************** Fieldpane **********************/
		fieldPane = new JPanel(new BorderLayout());
		contentPane.add(fieldPane, BorderLayout.CENTER);

		JScrollPane scrollPane = new JScrollPane();
		fieldPane.add(scrollPane, BorderLayout.CENTER);

		table = new JTable();
		scrollPane.setViewportView(table);

		baixaPane = new JPanel(new BorderLayout());
		fieldPane.add(baixaPane, BorderLayout.SOUTH);

		balancePane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 5));
		baixaPane.add(balancePane, BorderLayout.CENTER);

		lbVl_Vencimento = new JLabel("0,00");
		lbVl_Vencimento.setHorizontalAlignment(SwingConstants.RIGHT);
		balancePane.add(lbVl_Vencimento);

		JPanel panel = new JPanel(new GridBagLayout());
		panel.setBorder(new TitledBorder(null, "Pagamento",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));
		baixaPane.add(panel, BorderLayout.WEST);

		ftPagamento = new JFormattedTextField(mfd);
		panel.add(ftPagamento, new GridBagConstraints(0, 0, 1, 1, 1, 0,
				GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL,
				new Insets(2, 2, 2, 2), 40, 0));

		JButton btnGravar = new JButton("Gravar");
		btnGravar.setContentAreaFilled(false);
		btnGravar.setIcon(new ImageIcon(JIFLancamento.class
				.getResource("/img/tick.png")));

		btnGravar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

			}
		});

		btnGravar.setMnemonic('G');
		panel.add(btnGravar, new GridBagConstraints(1, 0, 1, 1, 0, 0,
				GridBagConstraints.WEST, GridBagConstraints.WEST, new Insets(2,
						2, 2, 2), 0, 0));

		/******************** Button Pane *************************/

		buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 5));
		contentPane.add(buttonPane, BorderLayout.SOUTH);

		JButton btnNovo = new JButton("Novo");
		btnNovo.setContentAreaFilled(false);
		btnNovo.setIcon(new ImageIcon(JIFLancamento.class
				.getResource("/img/textfield.png")));
		btnNovo.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
			}
		});
		btnNovo.setMnemonic('N');
		buttonPane.add(btnNovo);

		JButton btnEditar = new JButton("Editar");
		btnEditar.setContentAreaFilled(false);
		btnEditar.setIcon(new ImageIcon(JIFLancamento.class
				.getResource("/img/textfield_rename.png")));
		btnEditar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
			}
		});
		btnEditar.setMnemonic('E');
		buttonPane.add(btnEditar);

		JButton btnExcluir = new JButton("Excluir");
		btnExcluir.setContentAreaFilled(false);
		btnExcluir.setIcon(new ImageIcon(JIFLancamento.class
				.getResource("/img/delete.png")));
		btnExcluir.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

			}
		});
		btnExcluir.setMnemonic('X');
		buttonPane.add(btnExcluir);

		
	}

	
}
